import { Injectable } from '@angular/core';
import { HttpClient } from "@angular/common/http";

import { GlobalSettingService } from '../services/global-setting.service';


@Injectable()
export class AccountService {

  constructor(private http: HttpClient, private globalSettingService: GlobalSettingService) { }

  public login(account: any): any {

    return this.http.post(this.globalSettingService.getLibraryWebApiRootUrl() + 'member/login', {
      phone: account.phone,
      password: account.password
    });
  }

  public reset(id: string, password: string): any {

    return this.http.post(this.globalSettingService.getLibraryWebApiRootUrl() + 'member/reset', {
      id: id,
      password: password
    });
  }

  public verifyCodeForReset(phone: string, code: string): any {

    return this.http.post(this.globalSettingService.getLibraryWebApiRootUrl() + 'member/VerifyCodeForReset', {
      phone: phone,
      code: code
    });
  }

  public sendCodeForReset(phone: string): any {

    return this.http.get(this.globalSettingService.getLibraryWebApiRootUrl() + 'member/SendCodeForReset', {
      params: { phone: phone }
    });
  }

}
